﻿using System;
using System.Windows;
using SpecFlowTfsConnector;
using SpecFlowTfsLinker.Entities;

namespace SpecFlowTfsLinkerAddIn
{
    public partial class UserStorySelector : Window
    {
        public readonly UserStorySelectorModel Model;

        public UserStorySelector(TfsSpecFlowConnector tfsConnector)
        {
            InitializeComponent();

            if (tfsConnector == null)
                throw new ArgumentNullException("Tfs Connector cannot be null");

            Model = new UserStorySelectorModel(tfsConnector);
            DataContext = Model;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void tbRecherche_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            cbxUserStories.Items.Filter = us => ((UserStory) us).Title.Contains(tbRecherche.Text);
        }
    }
}